//
//  LGForumReplayDetailViewController.m
//  ligenyun
//
//  Created by Mac on 2018/4/10.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGForumReplayDetailViewController.h"
#import "LGforumReplayTableViewCell.h"
#import "LGCultureDetailViewController.h"
@interface LGForumReplayDetailViewController ()

@end

@implementation LGForumReplayDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"回复详情";
    [self configSubView];
    [self configFooterAndBottomView];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    __weak typeof(self) weakSelf =  self;
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 30)];
    header.backgroundColor = [UIColor whiteColor];
    STButton *  iconButton = [[STButton alloc] initWithFrame:CGRectMake(15, 10, 60, 60)
                                                title:nil
                                           titleColor:nil
                                            titleFont:0
                                         cornerRadius:30
                                      backgroundColor:nil
                                      backgroundImage:[UIImage imageNamed:@"1"]
                                                image:nil];
    [header addSubview:iconButton];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(iconButton.right + 10,10, UIScreenWidth -  iconButton.right, 20)
                                                     text:@"stoneobs"
                                                textColor:FirstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [NSString lableAutoAdjustWitdhWithLabel:titleLable];
    [header  addSubview: titleLable];
    
    
    NSDate * date = [NSDate st_localCurrentDate];
    STLabel * timeLable = [[STLabel alloc] initWithFrame:CGRectMake( titleLable.right+30,10, 50, 20)
                                                    text:date.st_dynamicFormater
                                               textColor:SecendTextColor
                                                    font:11
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [header  addSubview: timeLable];
    
    
    STLabel * desLable = [[STLabel alloc] initWithFrame:CGRectMake( iconButton.right+ 10, titleLable.bottom, UIScreenWidth -  iconButton.right - 15, 40)
                                                   text:@"祭祀是华夏名族离店的一部分祭祀是华夏名族离店的一部分祭祀是华夏名族离店的一部分"
                                              textColor:SecendTextColor
                                                   font:12
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
     desLable = desLable;
    [header  addSubview: desLable];
    
    
    
    STButton * lookButton = [[STButton alloc] initWithFrame:CGRectMake(titleLable.left ,desLable.bottom , 140, 44)
                                                        title:@"查看原帖"
                                                   titleColor:TM_redColor
                                                    titleFont:14
                                                 cornerRadius:0
                                              backgroundColor:nil
                                              backgroundImage:nil
                                                        image:nil];
    [lookButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedLookButton];
    }];
    [header  addSubview:lookButton];
    
    
    
    STButton * goodButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)
                                                title:nil
                                           titleColor:nil
                                            titleFont:0
                                         cornerRadius:0
                                      backgroundColor:nil
                                      backgroundImage:nil
                                                image:[UIImage imageNamed:@"已点赞"]];
     goodButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
     goodButton.centerY =  lookButton.centerY;
     goodButton.left =  lookButton.right + 20;
    [header addSubview: goodButton];
    
    
     STButton *   commentButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)
                                                   title:nil
                                              titleColor:nil
                                               titleFont:0
                                            cornerRadius:0
                                         backgroundColor:nil
                                         backgroundImage:nil
                                                   image:[UIImage imageNamed:@"论坛_消息"]];
     commentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
     commentButton.centerY =  lookButton.centerY;
     commentButton.left =  goodButton.right ;
    [header  addSubview: commentButton];
    
    header.height = commentButton.bottom + 5;
    self.tableView.tableHeaderView = header;
    header.backgroundColor = self.tableView.backgroundColor;
    
}
- (void)configFooterAndBottomView{
    UIView * footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    self.tableView.tableFooterView = footer;
    __weak typeof(self) weakSelf =  self;
    UIView * bootomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    bootomView.top = [TMUtils tabBarTop];
    bootomView.backgroundColor = [UIColor whiteColor];
    [bootomView st_showTopShadow];
    STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake(0, 1, UIScreenWidth, 48)
                                                     title:@"说点什么吧"
                                                titleColor:SecendTextColor
                                                 titleFont:14
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:nil];
    buyButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    [bootomView addSubview:buyButton];
    [buyButton setClicAction:^(UIButton *sender) {
        LGCultureCommentPresentController * vc = [LGCultureCommentPresentController new];
        [vc setOnSelctedSendHandle:^(NSString *text) {
            
        }];
        [weakSelf presentViewController:vc animated:NO completion:nil];
    }];
    [self.view addSubview:bootomView];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 20   ;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [LGforumReplayTableViewCell cellHeight];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    LGforumReplayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[LGforumReplayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma mark --Action Method
- (void)onSelctedLookButton{
    [self.navigationController pushViewController:[LGCultureDetailViewController new] animated:YES];
}
@end
